package yz.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class demo2UpFile {
    public static void main(String[] args) throws Exception{
        //创建连接
        Configuration entries = new Configuration();
        entries.set("fs.defaultFS","hdfs://master:9001");

        //修改使用者方式一
        //FileSystem fileSystem = FileSystem.get(new URI("hdfs://master:9001"), entries,"root");

        //方式二  设置系统变量
        System.setProperty("HADOOP_USER_NAME","root");

        //方式三
        //在VM环境中配置 HADOOP_USER_NAME=root


        FileSystem fileSystem = FileSystem.get(entries);
        fileSystem.copyFromLocalFile(new Path("src/main/dataFile/apiwolds.txt"),new Path("/api"));

        fileSystem.close();
    }
}
